package com.epic.dagger.tutorial;

import javax.inject.Inject;
import java.util.List;

public class LoginCommand extends  SingleArgsCommand{
    private final Outputter outputter;
    private final Database database;

    @Inject
    LoginCommand(Database database, Outputter outputter) {
        this.database = database;
        this.outputter = outputter;
    }

    @Override
    public String key() {
        return "login";
    }

    @Override
    public Result handleInput(List<String> input) {
        return super.handleInput(input);
    }

    @Override
    protected Result handleArg(String args) {
        Database.Account account = database.getAccount(args);
        outputter.output(args + " is logged in with database " + account.balance());
        return Result.handled();
    }
}
